import React from "react";

export default class render extends React.Component{
    state = {
        visible: true,
    }

    toggle(){
        this.setState({
            visible: !this.state.visible,
        })
    }
    creatHello(){
        if(this.state.visible){
            return <div>hello</div>
        }
        return null
    }
    render(){
        return (
            <div>
                {this.creatHello()}
                {/* {this.state.visible? <div>hello</div>: null } */}
                <button onClick={this.toggle.bind(this)}>
                    { this.state.visible? '隐藏': '显示'}
                </button>
            </div>
        )
    }

}
